package Easy爬楼梯;

import org.testng.annotations.Test;

public class Solution {
    public int climbStairs(int n) {
        if(n == 1)
            return 1;
        else if (n == 2)
            return 2;
        else
            return climbStairs(n-1)+climbStairs(n-2);
    }

    public int climbStairs1(int n){
        int[] a = new int[46];
        a[1] = 1;
        a[2] = 2;
        for (int i = 3; i <= n; i++)
            a[i] = a[i-1] + a[i-2];
        return a[n];
    }

    @Test
    public void test(){
        System.out.println(climbStairs1(1));
    }
}
